namespace devtm.Aop.Emit
{
    using System;
    

    [Serializable]
    public class EmitCatchClause
    {

        private string localName;
        private EmitStatementCollection statements;

        public EmitCatchClause()
        {
        }

        public EmitCatchClause(string localName)
        {
            this.localName = localName;
        }

        public EmitCatchClause(string localName, EmitTypeReference catchExceptionType)
        {
            this.localName = localName;
            this.CatchExceptionType = catchExceptionType;
        }

        public EmitCatchClause(string localName, EmitTypeReference catchExceptionType, params EmitStatement[] statements)
        {
            this.localName = localName;
            this.CatchExceptionType = catchExceptionType;
            this.Statements.AddRange(statements);
        }

        public EmitTypeReference CatchExceptionType        {            get            ;            set            ;        }

        public string LocalName
        {
            get
            {
                if (this.localName != null)
                {
                    return this.localName;
                }
                return string.Empty;
            }
            set
            {
                this.localName = value;
            }
        }

        public EmitStatementCollection Statements
        {
            get
            {
                if (this.statements == null)
                {
                    this.statements = new EmitStatementCollection();
                }
                return this.statements;
            }
        }

        // this.catchExceptionType = new EmitTypeReference(typeof(Exception));

    }
}
